package com.my.fp.list;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: marshal
 * @date: 2022-01-07 11:10 AM
 */
public class GroupbyTest {
    public static void main(String[] args) {
        List<Tunnel> tunnelList = initData();
        System.out.println(tunnelList);
        List<Tunnel> list = tunnelList.stream().sorted(Comparator.comparing(Tunnel::getName)).collect(Collectors.toList());
        System.out.println(list);
    }

    private static List<Tunnel> initData() {
        List<Tunnel> list = new ArrayList<>(4);
        list.add(new Tunnel(1L, "以头隧道", 0, 100, 200));
        list.add(new Tunnel(3L, "沙密开隧道", 0, 400, 500));
        list.add(new Tunnel(4L, "沙密开隧道", 1, 410, 520));
        list.add(new Tunnel(2L, "以头隧道", 1, 90, 190));
        return list;
    }
}

/**
 * 隧道
 */
class Tunnel{
    public Tunnel(Long id, String name, Integer direction, Integer startStake, Integer endStake) {
        this.id = id;
        this.name = name;
        this.direction = direction;
        this.startStake = startStake;
        this.endStake = endStake;
    }

    private Long id;
    private String name;
    private Integer direction;
    private Integer startStake;
    private Integer endStake;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getDirection() {
        return direction;
    }

    public void setDirection(Integer direction) {
        this.direction = direction;
    }

    public Integer getStartStake() {
        return startStake;
    }

    public void setStartStake(Integer startStake) {
        this.startStake = startStake;
    }

    public Integer getEndStake() {
        return endStake;
    }

    public void setEndStake(Integer endStake) {
        this.endStake = endStake;
    }

    @Override
    public String toString() {
        return "Tunnel{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", direction=" + direction +
                ", startStake=" + startStake +
                ", endStake=" + endStake +
                '}';
    }
}
